Hệ thống hiệu sách thương mại điện tử

1 <?php
2 session_start();
3 include
"dbconnect.php";
4
5 if
(isset($_GET['Message'])) {
6     print
'<script type="text/javascript">
7                alert(
"' . $_GET['Message'] . '");
8            </script>
';
9 }

10
11 if
(isset($_GET['response'])) {
12     print
'<script type="text/javascript">
13                alert(
"' . $_GET['response'] . '");
14            </script>
';
15 }

16
17 if
(isset($_POST['submit']))
18 {
19   
if($_POST['submit']=="login")
20   {
21         $username=$_POST[
'login_username'];
22         $password=$_POST[
'login_password'];
23         $query =
"SELECT * from users where UserName ='$username' AND Password='$password'";
24         $result = mysqli_query($con,$query)or die(mysql_error());
25         
if(mysqli_num_rows($result) > 0)
26         {
27              $row = mysqli_fetch_assoc($result);
28              $_SESSION[
'user']=$row['UserName'];
29              print
'
30                 <script type=
"text/javascript">alert("successfully logged in!!!");</script>
31                   
';
32         }
33         
else
34         { print
'
35               <script type=
"text/javascript">alert("Incorrect Username Or Password!!");</script>
36                   
';
37         }
38   }
39   
else if($_POST['submit']=="register")
40   {
41         $username=$_POST[
'register_username'];
42         $password=$_POST[
'register_password'];
43         $query=
"select * from users where UserName = '$username'";
44         $result=mysqli_query($con,$query) or die(mysql_error);
45         
if(mysqli_num_rows($result)>0)
46         {
47                print
'
48                <script type=
"text/javascript">alert("username is taken");</script>
49                     
';
50
51         }
52         
else
53         {
54           $query =
"INSERT INTO users VALUES ('$username','$password')";
55           $result=mysqli_query($con,$query);
56           print
'
57                 <script type=
"text/javascript">
58                  alert(
"Successfully Registered!!!");
59                 </script>
60                
';
61         }
62   }
63 }
64 ?>
65
66
67 <!DOCTYPE html>
68 <html lang=
"en">
69 <head>
70
71     <meta charset=
"utf-8">
72     <meta http-equiv=
"X-UA-Compatible" content="IE=edge">
73     <meta name=
"viewport" content="width=device-width, initial-scale=1">
74     <meta name=
"description" content="Books">
75     <meta name=
"author" content="Shivangi Gupta">
76     <title>Online Bookstore</title>
77     <!-- Bootstrap -->
78     <link href=
"css/bootstrap.min.css" rel="stylesheet">
79     <link href=
"css/my.css" rel="stylesheet">
80     <style>
81       .modal-header {background:#D67B22;color:#fff;font-weight:
800;}
82       .modal-body{font-weight:
800;}
83       .modal-body ul{list-style:none;}
84       .modal .btn {background:#D67B22;color:#fff;}
85       .modal a{color:#D67B22;}
86       .modal-backdrop {position:inherit !important;}
87        #login_button,#register_button{background:none;color:#D67B22!important;}
88        #query_button {position:
fixed;right:0px;bottom:0px;padding:10px 80px;
89                       background-color:#D67B22;color:#fff;border-color:#f05f40;border-radius:2px;}
90     @media(max-width:767px){
91         #query_button {padding: 5px 20px;}
92     }
93     </style>
94 </head>
95 <body>
96   <nav
class="navbar navbar-default navbar-fixed-top navbar-inverse">
97       <div
class="container-fluid">
98         <!-- Brand and toggle
get grouped for better mobile display -->
99         <div
class="navbar-header">
100           <button type=
"button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
101             <span
class="sr-only">Toggle navigation</span>
102             <span
class="icon-bar"></span>
103             <span
class="icon-bar"></span>
104             <span
class="icon-bar"></span>
105           </button>
106           <a
class="navbar-brand" href="#" style="padding: 1px;"><img class="img-responsive" alt="Brand" src="img/logo.jpg" style="width: 147px;margin: 0px;"></a>
107         </div>
108
109         <!-- Collect the nav links, forms, and other content
for toggling -->
110         <div
class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
111          <ul
class="nav navbar-nav navbar-right">
112         <?php
113         
if(!isset($_SESSION['user']))
114           {
115             echo
'
116             <li>
117                 <button type=
"button" id="login_button" class="btn btn-lg" data-toggle="modal" data-target="#login">Login</button>
118                   <div id=
"login" class="modal fade" role="dialog">
119                     <div
class="modal-dialog">
120                         <div
class="modal-content">
121                             <div
class="modal-header">
122                                 <button type=
"button" class="close" data-dismiss="modal">&times;</button>
123                                 <h4
class="modal-title text-center">Login Form</h4>
124                             </div>
125                             <div
class="modal-body">
126                                           <form
class="form" role="form" method="post" action="index.php" accept-charset="UTF-8">
127                                               <div
class="form-group">
128                                                   <label
class="sr-only" for="username">Username</label>
129                                                   <input type=
"text" name="login_username" class="form-control" placeholder="Username" required>
130                                               </div>
131                                               <div
class="form-group">
132                                                   <label
class="sr-only" for="password">Password</label>
133                                                   <input type=
"password" name="login_password" class="form-control" placeholder="Password" required>
134                                               </div>
135                                               <div
class="form-group">
136                                                   <button type=
"submit" name="submit" value="login" class="btn btn-block">
137                                                       Sign
in
138                                                   </button>
139                                               </div>
140                                           </form>
141                             </div>
142                             <div
class="modal-footer">
143                                 <button type=
"button" class="btn btn-default" data-dismiss="modal">Close</button>
144                             </div>
145                         </div>
146                     </div>
147                   </div>
148             </li>
149             <li>
150               <button type=
"button" id="register_button" class="btn btn-lg" data-toggle="modal" data-target="#register">Sign Up</button>
151                 <div id=
"register" class="modal fade" role="dialog">
152                   <div
class="modal-dialog">
153                       <div
class="modal-content">
154                           <div
class="modal-header">
155                               <button type=
"button" class="close" data-dismiss="modal">&times;</button>
156                               <h4
class="modal-title text-center">Member Registration Form</h4>
157                           </div>
158                           <div
class="modal-body">
159                                         <form
class="form" role="form" method="post" action="index.php" accept-charset="UTF-8">
160                                             <div
class="form-group">
161                                                 <label
class="sr-only" for="username">Username</label>
162                                                 <input type=
"text" name="register_username" class="form-control" placeholder="Username" required>
163                                             </div>
164                                             <div
class="form-group">
165                                                 <label
class="sr-only" for="password">Password</label>
166                                                 <input type=
"password" name="register_password" class="form-control" placeholder="Password" required>
167                                             </div>
168                                             <div
class="form-group">
169                                                 <button type=
"submit" name="submit" value="register" class="btn btn-block">
170                                                     Sign Up
171                                                 </button>
172                                             </div>
173                                         </form>
174                           </div>
175                           <div
class="modal-footer">
176                               <button type=
"button" class="btn btn-default" data-dismiss="modal">Close</button>
177                           </div>
178                       </div>
179                   </div>
180                 </div>
181             </li>
';
182           }
183         
else
184           { echo
' <li> <a href="#" class="btn btn-lg"> Hello ' .$_SESSION['user']. '.</a></li>
185                     <li> <a href=
"cart.php" class="btn btn-lg"> Cart </a> </li>;
186                     <li> <a href=
"destroy.php" class="btn btn-lg"> LogOut </a> </li>';
187                
188           }
189 ?>
190
191           </ul>
192         </div><!-- /.navbar-collapse -->
193       </div><!-- /.container-fluid -->
194     </nav>
195   <div id=
"top" >
196       <div id=
"searchbox" class="container-fluid" style="width:112%;margin-left:-6%;margin-right:-6%;">
197           <div>
198               <form role=
"search" method="POST" action="Result.php">
199                   <input type=
"text" class="form-control" name="keyword" style="width:80%;margin:20px 10% 20px 10%;" placeholder="Search for a Book , Author Or Category">
200               </form>
201           </div>
202       </div>
203
204       <div
class="container-fluid" id="header">
205           <div
class="row">
206               <div
class="col-md-3 col-lg-3" id="category">
207                   <div style=
"background:#D67B22;color:#fff;font-weight:800;border:none;padding:15px;"> The Book Shop </div>
208                   <ul>
209                       <li> <a href=
"Product.php?value=entrance%20exam"> Entrance Exam </a> </li>
210                       <li> <a href=
"Product.php?value=Literature%20and%20Fiction"> Literature & Fiction </a> </li>
211                       <li> <a href=
"Product.php?value=Academic%20and%20Professional"> Academic & Professional </a> </li>
212                       <li> <a href=
"Product.php?value=Biographies%20and%20Auto%20Biographies"> Biographies & Auto Biographies </a> </li>
213                       <li> <a href=
"Product.php?value=Children%20and%20Teens"> Children & Teens </a> </li>
214                       <li> <a href=
"Product.php?value=Regional%20Books"> Regional Books </a> </li>
215                       <li> <a href=
"Product.php?value=Business%20and%20Management"> Business & Management </a> </li>
216                       <li> <a href=
"Product.php?value=Health%20and%20Cooking"> Health and Cooking </a> </li>
217
218                   </ul>
219               </div>
220               <div
class="col-md-6 col-lg-6">
221                   <div id=
"myCarousel" class="carousel slide carousel-fade" data-ride="carousel">
222                       <!-- Indicators -->
223                       <ol
class="carousel-indicators">
224                           <li data-target=
"#myCarousel" data-slide-to="0" class="active"></li>
225                           <li data-target=
"#myCarousel" data-slide-to="1"></li>
226                           <li data-target=
"#myCarousel" data-slide-to="2"></li>
227                           <li data-target=
"#myCarousel" data-slide-to="3"></li>
228                           <li data-target=
"#myCarousel" data-slide-to="4"></li>
229                           <li data-target=
"#myCarousel" data-slide-to="5"></li>
230                       </ol>
231                       
232                         <!-- Wrapper
for slides -->
233                       <div
class="carousel-inner" role="listbox">
234                           <div
class="item active">
235                             <img
class="img-responsive" src="img/carousel/1.jpg">
236                           </div>
237
238                           <div
class="item">
239                             <img
class="img-responsive "src="img/carousel/2.jpg">
240                           </div>
241
242                           <div
class="item">
243                             <img
class="img-responsive" src="img/carousel/3.jpg">
244                           </div>
245
246                           <div
class="item">
247                             <img
class="img-responsive"src="img/carousel/4.jpg">
248                           </div>
249
250                           <div
class="item">
251                             <img
class="img-responsive" src="img/carousel/5.jpg">
252                           </div>
253
254                           <div
class="item">
255                             <img
class="img-responsive" src="img/carousel/6.jpg">
256                           </div>
257                       </div>
258                   </div>
259               </div>
260               <div
class="col-md-3 col-lg-3" id="offer">
261                   <a href=
"Product.php?value=Regional%20Books"> <img class="img-responsive center-block" src="img/offers/1.png"></a>
262                   <a href=
"Product.php?value=Health%20and%20Cooking"> <img class="img-responsive center-block" src="img/offers/2.png"></a>
263                   <a href=
"Product.php?value=Academic%20and%20Professional"> <img class="img-responsive center-block" src="img/offers/3.png"></a>
264               </div>
265           </div>
266       </div>
267   </div>
268
269   <div
class="container-fluid text-center" id="new">
270       <div
class="row">
271           <div
class="col-sm-6 col-md-3 col-lg-3">
272            <a href=
"description.php?ID=NEW-1&category=new">
273               <div
class="book-block">
274                   <div
class="tag">New</div>
275                   <div
class="tag-side"><img src="img/tag.png"></div>
276                   <img
class="book block-center img-responsive" src="img/new/1.jpg">
277                   <hr>
278                   Like A Love Song <br>
279                   Rs
113 &nbsp
280                   <span style=
"text-decoration:line-through;color:#828282;"> 175 </span>
281                   <span
class="label label-warning">35%</span>
282               </div>
283             </a>
284           </div>
285           <div
class="col-sm-6 col-md-3 col-lg-3">
286            <a href=
"description.php?ID=NEW-2&category=new">
287               <div
class="book-block">
288                   <div
class="tag">New</div>
289                   <div
class="tag-side"><img src="img/tag.png"></div>
290                   <img
class="block-center img-responsive" src="img/new/2.jpg">
291                   <hr>
292                   General Knowledge
2017 <br>
293                   Rs
68 &nbsp
294                   <span style=
"text-decoration:line-through;color:#828282;"> 120 </span>
295                   <span
class="label label-warning">43%</span>
296               </div>
297             </a>
298           </div>
299           <div
class="col-sm-6 col-md-3 col-lg-3">
300            <a href=
"description.php?ID=NEW-3&category=new">
301               <div
class="book-block">
302                   <div
class="tag">New</div>
303                   <div
class="tag-side"><img src="img/tag.png"></div>
304                   <img
class="block-center img-responsive" src="img/new/3.png">
305                   <hr>
306                   Indian Family Bussiness Mantras <br>
307                   Rs
400 &nbsp
308                   <span style=
"text-decoration:line-through;color:#828282;"> 595 </span>
309                   <span
class="label label-warning">33%</span>
310               </div>
311             </a>
312           </div>
313           <div
class="col-sm-6 col-md-3 col-lg-3">
314            <a href=
"description.php?ID=NEW-4&category=new">
315               <div
class="book-block">
316                   <div
class="tag">New</div>
317                   <div
class="tag-side"><img src="img/tag.png"></div>
318                   <img
class="block-center img-responsive" src="img/new/4.jpg">
319                   <hr>
320                   Kiran s SSC Mathematics Chapterwise Solutions <br>
321                   Rs
289 &nbsp
322                   <span style=
"text-decoration:line-through;color:#828282;"> 435 </span>
323                   <span
class="label label-warning">33%</span>
324               </div>
325             </a>
326           </div>
327       </div>
328   </div>
329
330   <div
class="container-fluid" id="author">
331       <h3 style=
"color:#D67B22;"> POPULAR AUTHORS </h3>
332       <div
class="row">
333           <div
class="col-sm-5 col-md-3 col-lg-3">
334               <a href=
"Author.php?value=Durjoy%20Datta"><img class="img-responsive center-block" src="img/popular-author/0.jpg"></a>
335           </div>
336           <div
class="col-sm-6 col-md-3 col-lg-3">
337               <a href=
"Author.php?value=Chetan%20Bhagat"><img class="img-responsive center-block" src="img/popular-author/1.jpg"></a>
338           </div>
339           <div
class="col-sm-6 col-md-3 col-lg-3">
340               <a href=
"Author.php?value=Dan%20Brown"><img class="img-responsive center-block" src="img/popular-author/2.jpg"></a>
341           </div>
342           <div
class="col-sm-6 col-md-3 col-lg-3">
343               <a href=
"Author.php?value=Ravinder%20Singh"><img class="img-responsive center-block" src="img/popular-author/3.jpg"></a>
344           </div>
345       </div>
346       <div
class="row">
347           <div
class="col-sm-5 col-md-3 col-lg-3">
348               <a href=
"Author.php?value=Jeffrey%20Archer"><img class="img-responsive center-block" src="img/popular-author/4.jpg"></a>
349           </div>
350           <div
class="col-sm-6 col-md-3 col-lg-3">
351               <a href=
"Author.php?value=Salman%20Rushdie"><img class="img-responsive center-block" src="img/popular-author/5.jpg"><a>
352           </div>
353           <div
class="col-sm-6 col-md-3 col-lg-3">
354               <a href=
"Author.php?value=J%20K%20Rowling"><img class="img-responsive center-block" src="img/popular-author/6.jpg"></a>
355           </div>
356           <div
class="col-sm-6 col-md-3 col-lg-3">
357               <a href=
"Author.php?value=Subrata%20Roy"><img class="img-responsive center-block" src="img/popular-author/7.jpg"></a>
358           </div>
359       </div>
360   </div>
361
362   <footer style=
"margin-left:-6%;margin-right:-6%;">
363       <div
class="container-fluid">
364           <div
class="row">
365               <div
class="col-sm-1 col-md-1 col-lg-1">
366               </div>
367               <div
class="col-sm-7 col-md-5 col-lg-5">
368                   <div
class="row text-center">
369                       <h2>Let
's Get In Touch!</h2>
370                       <hr
class="primary">
371                       <p>Still Confused? Give us a call or send us an email and we will
get back to you as soon as possible!</p>
372                   </div>
373                   <div
class="row">
374                       <div
class="col-md-6 text-center">
375                           <span
class="glyphicon glyphicon-earphone"></span>
376                           <p>
123-456-6789</p>
377                       </div>
378                       <div
class="col-md-6 text-center">
379                           <span
class="glyphicon glyphicon-envelope"></span>
380                           <p>BookStore@gmail.com</p>
381                       </div>
382                   </div>
383               </div>
384               <div
class="hidden-sm-down col-md-2 col-lg-2">
385               </div>
386               <div
class="col-sm-4 col-md-3 col-lg-3 text-center">
387                   <h2 style=
"color:#D67B22;">Follow Us At</h2>
388                   <div>
389                       <a href=
"https://twitter.com/strandbookstore">
390                       <img title=
"Twitter" alt="Twitter" src="img/social/twitter.png" width="35" height="35" />
391                       </a>
392                       <a href=
"https://www.linkedin.com/company/strand-book-store">
393                       <img title=
"LinkedIn" alt="LinkedIn" src="img/social/linkedin.png" width="35" height="35" />
394                       </a>
395                       <a href=
"https://www.facebook.com/strandbookstore/">
396                       <img title=
"Facebook" alt="Facebook" src="img/social/facebook.png" width="35" height="35" />
397                       </a>
398                       <a href=
"https://plus.google.com/111917722383378485041">
399                       <img title=
"google+" alt="google+" src="img/social/google.jpg" width="35" height="35" />
400                       </a>
401                       <a href=
"https://www.pinterest.com/strandbookstore/">
402                       <img title=
"Pinterest" alt="Pinterest" src="img/social/pinterest.jpg" width="35" height="35" />
403                       </a>
404                   </div>
405               </div>
406           </div>
407       </div>
408   </footer>
409
410 <div
class="container">
411   <!-- Trigger the modal with a button -->
412   <button type=
"button" id="query_button" class="btn btn-lg" data-toggle="modal" data-target="#query">Ask query</button>
413   <!-- Modal -->
414   <div
class="modal fade" id="query" role="dialog">
415     <div
class="modal-dialog">
416       <div
class="modal-content">
417           <div
class="modal-header text-center">
418             <button type=
"button" class="close" data-dismiss="modal">&times;</button>
419             <h4
class="modal-title">Ask your query here</h4>
420           </div>
421           <div
class="modal-body">
422                     <form method=
"post" action="query.php" class="form" role="form">
423                         <div
class="form-group">
424                              <label
class="sr-only" for="name">Name</label>
425                              <input type=
"text" class="form-control" placeholder="Your Name" name="sender" required>
426                         </div>
427                         <div
class="form-group">
428                              <label
class="sr-only" for="email">Email</label>
429                              <input type=
"email" class="form-control" placeholder="abc@gmail.com" name="senderEmail" required>
430                         </div>
431                         <div
class="form-group">
432                              <label
class="sr-only" for="query">Message</label>
433                              <textarea
class="form-control" rows="5" cols="30" name="message" placeholder="Your Query" required></textarea>
434                         </div>
435                         <div
class="form-group">
436                               <button type=
"submit" name="submit" value="query" class="btn btn-block">
437                                                               Send Query
438                                </button>
439                         </div>
440                     </form>
441           </div>
442           <div
class="modal-footer">
443               <button type=
"button" class="btn btn-default" data-dismiss="modal">Close</button>
444           </div>
445       </div>
446     </div>
447   </div>
448 </div>
449
450   <!-- jQuery (necessary
for Bootstrap's JavaScript plugins) -->
451   <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
452   <!-- Include all compiled plugins (below), or include individual files
as needed -->
453   <script src=
"js/bootstrap.min.js"></script>
454 </body>
455 </html>


Gõ tìm kiếm nhanh...